﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace lab2
{
    public partial class addReis : Form
    {
        public addReis()
        {
            InitializeComponent();
        }

        OleDbConnection cn;
        OleDbCommand cm;

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.ToString() == "" || textBox2.Text.ToString() == "" || textBox3.Text.ToString() == "")
            {
                errorForm frm = new errorForm();
                frm.Show();
            }
            else
            {
                cn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = D:\\studying\\6sem\\БД\\Student\\passengers.mdb");
                cn.Open();


                string test = "INSERT INTO Рейсы ( flight_num, `from`, `to` ) VALUES ('" + textBox1.Text.ToString() + "', '" + textBox2.Text.ToString() + "', '" + textBox3.Text.ToString() + "')";
                cm = new OleDbCommand(test, cn);
                cm.ExecuteNonQuery();
                cm.Dispose();
                cn.Close();
                cm.Dispose();
                this.Close();
            }
        }
    }
}
